# pip install flask
from flask import Flask, render_template, request

# 创建服务
app = Flask(__name__)

data = [
    {'id': 0, 'name': '中秋节', 'num': 0},
    {'id': 1, 'name': '中秋节', 'num': 1},
    {'id': 2, 'name': '中秋节', 'num': 2},
]


@app.route('/')
def login():
    return render_template('login.html')


@app.route('/index', methods=['POST'])
def index():
    # post请求获取用户名
    # print(request.method)
    # username = request.args.get('username')
    username = request.form.get('username')
    # print(username)
    password = request.args.get('password')
    return render_template('index.html', data=data)


@app.route('/click')
def click_btn():
    id = request.args.get('id')
    print(id)
    data[int(id)]['num'] += 1
    return render_template('index.html', data=data)


# 启动服务
app.run(debug=True)
